package com.zb.internetSpider.gui.asiderPanel;


import java.awt.BorderLayout;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import com.zb.internetSpider.gui.SpiderComponent;
import com.zb.internetSpider.gui.SpiderContainer;
import com.zb.internetSpider.gui.tree.AbstractSpiderTree;

/**
 * <p>爬虫侧边栏接口</p>
 * @author 张贝
 *
 */
public abstract  class AbstractSpiderAsiderPanel extends JPanel implements SpiderContainer {
	
	protected List<SpiderContainer> containers;

	protected List<SpiderComponent> components;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3153979303146271711L;
	
	
	public AbstractSpiderAsiderPanel() {
		// TODO Auto-generated constructor stub		
		super.setLayout( new BorderLayout());	
	}
	
	
	public void init(){
		if(this.containers != null)
			for(SpiderContainer container : this.containers) {
				container.init();
			}
	}

	/**
	 * 
	 * @Description: TODO 添加菜单树
	 * @param @param tree   
	 * @return void  
	 * @throws
	 * @author zb
	 * @date 2019年2月17日 上午12:21:58
	 */
	public void setMenu(AbstractSpiderTree tree) {		
		tree.setAutoscrolls(true);
		JScrollPane jScrollPane = new JScrollPane(tree);
		jScrollPane.setAutoscrolls(true);
		super.add(jScrollPane, BorderLayout.CENTER);
		this.setSpiderContainers(tree);
	}

	@Override
	public void setBackGroundColor(Color color) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void setSpiderContainers(SpiderContainer... containers) {
		// TODO Auto-generated method stub
		if(this.containers == null){
			this.containers = new ArrayList<SpiderContainer>();
		}
		
		for(SpiderContainer sContainer: containers) {
			this.containers.add(sContainer);
//			if(sContainer instanceof AbstractSpiderTree){
//				/**
//				 * 添加菜单树
//				 */								
//				super.add((AbstractSpiderTree)sContainer, BorderLayout.CENTER);
//			}
		}
	}


	@Override
	public void setSpiderComponents(SpiderComponent... components) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public SpiderContainer[] getSpiderContainers() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public SpiderComponent[] getSpiderComponents() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public int SpiderContainersCount() {
		// TODO Auto-generated method stub
		return 0;
	}


	@Override
	public int SpiderComponentsCount() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	/**
	 * 
	 * @Description: TODO 添加子容器组件
	 * @param @param containers   
	 * @return void  
	 * @throws
	 * @author zb
	 * @date 2019年2月17日 上午12:35:07
	 */
	public abstract void addSpiderContainer(SpiderContainer... containers);

}
